1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.CellAreaContext; 26 27 private import gobject.ObjectG; 28 private import gtk.CellArea; 29 private import gtk.c.functions; 30 public import gtk.c.types; 31 32 33 /** 34 * Stores geometrical information for a series of rows in a GtkCellArea 35 * 36 * The `GtkCellAreaContext` object is created by a given `GtkCellArea` 37 * implementation via its `GtkCellAreaClass.create_context()` virtual 38 * method and is used to store cell sizes and alignments for a series of 39 * `GtkTreeModel` rows that are requested and rendered in the same context. 40 * 41 * `GtkCellLayout` widgets can create any number of contexts in which to 42 * request and render groups of data rows. However, it’s important that the 43 * same context which was used to request sizes for a given `GtkTreeModel` 44 * row also be used for the same row when calling other `GtkCellArea` APIs 45 * such as gtk_cell_area_render() and gtk_cell_area_event(). 46 */ 47 public class CellAreaContext : ObjectG 48 { 49 /** the main Gtk struct */ 50 protected GtkCellAreaContext* gtkCellAreaContext; 51 52 /** Get the main Gtk struct */ 53 public GtkCellAreaContext* getCellAreaContextStruct(bool transferOwnership = false) 54 { 55 if (transferOwnership) 56 ownedRef = false; 57 return gtkCellAreaContext; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)gtkCellAreaContext; 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (GtkCellAreaContext* gtkCellAreaContext, bool ownedRef = false) 70 { 71 this.gtkCellAreaContext = gtkCellAreaContext; 72 super(cast(GObject*)gtkCellAreaContext, ownedRef); 73 } 74 75 76 /** */ 77 public static GType getType() 78 { 79 return gtk_cell_area_context_get_type(); 80 } 81 82 /** 83 * Allocates a width and/or a height for all rows which are to be 84 * rendered with @context. 85 * 86 * Usually allocation is performed only horizontally or sometimes 87 * vertically since a group of rows are usually rendered side by 88 * side vertically or horizontally and share either the same width 89 * or the same height. Sometimes they are allocated in both horizontal 90 * and vertical orientations producing a homogeneous effect of the 91 * rows. This is generally the case for `GtkTreeView` when 92 * `GtkTreeView:fixed-height-mode` is enabled. 93 * 94 * Params: 95 * width = the allocated width for all `GtkTreeModel` rows rendered 96 * with @context, or -1 97 * height = the allocated height for all `GtkTreeModel` rows rendered 98 * with @context, or -1 99 */ 100 public void allocate(int width, int height) 101 { 102 gtk_cell_area_context_allocate(gtkCellAreaContext, width, height); 103 } 104 105 /** 106 * Fetches the current allocation size for @context. 107 * 108 * If the context was not allocated in width or height, or if the 109 * context was recently reset with gtk_cell_area_context_reset(), 110 * the returned value will be -1. 111 * 112 * Params: 113 * width = location to store the allocated width 114 * height = location to store the allocated height 115 */ 116 public void getAllocation(out int width, out int height) 117 { 118 gtk_cell_area_context_get_allocation(gtkCellAreaContext, &width, &height); 119 } 120 121 /** 122 * Fetches the `GtkCellArea` this @context was created by. 123 * 124 * This is generally unneeded by layouting widgets; however, 125 * it is important for the context implementation itself to 126 * fetch information about the area it is being used for. 127 * 128 * For instance at `GtkCellAreaContextClass.allocate()` time 129 * it’s important to know details about any cell spacing 130 * that the `GtkCellArea` is configured with in order to 131 * compute a proper allocation. 132 * 133 * Returns: the `GtkCellArea` this context was created by. 134 */ 135 public CellArea getArea() 136 { 137 auto __p = gtk_cell_area_context_get_area(gtkCellAreaContext); 138 139 if(__p is null) 140 { 141 return null; 142 } 143 144 return ObjectG.getDObject!(CellArea)(cast(GtkCellArea*) __p); 145 } 146 147 /** 148 * Gets the accumulative preferred height for all rows which have been 149 * requested with this context. 150 * 151 * After gtk_cell_area_context_reset() is called and/or before ever 152 * requesting the size of a `GtkCellArea`, the returned values are 0. 153 * 154 * Params: 155 * minimumHeight = location to store the minimum height 156 * naturalHeight = location to store the natural height 157 */ 158 public void getPreferredHeight(out int minimumHeight, out int naturalHeight) 159 { 160 gtk_cell_area_context_get_preferred_height(gtkCellAreaContext, &minimumHeight, &naturalHeight); 161 } 162 163 /** 164 * Gets the accumulative preferred height for @width for all rows 165 * which have been requested for the same said @width with this context. 166 * 167 * After gtk_cell_area_context_reset() is called and/or before ever 168 * requesting the size of a `GtkCellArea`, the returned values are -1. 169 * 170 * Params: 171 * width = a proposed width for allocation 172 * minimumHeight = location to store the minimum height 173 * naturalHeight = location to store the natural height 174 */ 175 public void getPreferredHeightForWidth(int width, out int minimumHeight, out int naturalHeight) 176 { 177 gtk_cell_area_context_get_preferred_height_for_width(gtkCellAreaContext, width, &minimumHeight, &naturalHeight); 178 } 179 180 /** 181 * Gets the accumulative preferred width for all rows which have been 182 * requested with this context. 183 * 184 * After gtk_cell_area_context_reset() is called and/or before ever 185 * requesting the size of a `GtkCellArea`, the returned values are 0. 186 * 187 * Params: 188 * minimumWidth = location to store the minimum width 189 * naturalWidth = location to store the natural width 190 */ 191 public void getPreferredWidth(out int minimumWidth, out int naturalWidth) 192 { 193 gtk_cell_area_context_get_preferred_width(gtkCellAreaContext, &minimumWidth, &naturalWidth); 194 } 195 196 /** 197 * Gets the accumulative preferred width for @height for all rows which 198 * have been requested for the same said @height with this context. 199 * 200 * After gtk_cell_area_context_reset() is called and/or before ever 201 * requesting the size of a `GtkCellArea`, the returned values are -1. 202 * 203 * Params: 204 * height = a proposed height for allocation 205 * minimumWidth = location to store the minimum width 206 * naturalWidth = location to store the natural width 207 */ 208 public void getPreferredWidthForHeight(int height, out int minimumWidth, out int naturalWidth) 209 { 210 gtk_cell_area_context_get_preferred_width_for_height(gtkCellAreaContext, height, &minimumWidth, &naturalWidth); 211 } 212 213 /** 214 * Causes the minimum and/or natural height to grow if the new 215 * proposed sizes exceed the current minimum and natural height. 216 * 217 * This is used by `GtkCellAreaContext` implementations during 218 * the request process over a series of `GtkTreeModel` rows to 219 * progressively push the requested height over a series of 220 * gtk_cell_area_get_preferred_height() requests. 221 * 222 * Params: 223 * minimumHeight = the proposed new minimum height for @context 224 * naturalHeight = the proposed new natural height for @context 225 */ 226 public void pushPreferredHeight(int minimumHeight, int naturalHeight) 227 { 228 gtk_cell_area_context_push_preferred_height(gtkCellAreaContext, minimumHeight, naturalHeight); 229 } 230 231 /** 232 * Causes the minimum and/or natural width to grow if the new 233 * proposed sizes exceed the current minimum and natural width. 234 * 235 * This is used by `GtkCellAreaContext` implementations during 236 * the request process over a series of `GtkTreeModel` rows to 237 * progressively push the requested width over a series of 238 * gtk_cell_area_get_preferred_width() requests. 239 * 240 * Params: 241 * minimumWidth = the proposed new minimum width for @context 242 * naturalWidth = the proposed new natural width for @context 243 */ 244 public void pushPreferredWidth(int minimumWidth, int naturalWidth) 245 { 246 gtk_cell_area_context_push_preferred_width(gtkCellAreaContext, minimumWidth, naturalWidth); 247 } 248 249 /** 250 * Resets any previously cached request and allocation 251 * data. 252 * 253 * When underlying `GtkTreeModel` data changes its 254 * important to reset the context if the content 255 * size is allowed to shrink. If the content size 256 * is only allowed to grow (this is usually an option 257 * for views rendering large data stores as a measure 258 * of optimization), then only the row that changed 259 * or was inserted needs to be (re)requested with 260 * gtk_cell_area_get_preferred_width(). 261 * 262 * When the new overall size of the context requires 263 * that the allocated size changes (or whenever this 264 * allocation changes at all), the variable row 265 * sizes need to be re-requested for every row. 266 * 267 * For instance, if the rows are displayed all with 268 * the same width from top to bottom then a change 269 * in the allocated width necessitates a recalculation 270 * of all the displayed row heights using 271 * gtk_cell_area_get_preferred_height_for_width(). 272 */ 273 public void reset() 274 { 275 gtk_cell_area_context_reset(gtkCellAreaContext); 276 } 277 }